'''
作者:袁俊
描述: 将订单查询页面封装成一个类
'''
# 引入模块

from MY_ECShop.common.base import *
from MY_ECShop.page.Menu import PageMenu
import time



# 创建订单列表类
class PageOrderQuery(Base):
    # 类属性
    order_sn = ('name', 'order_sn')  # 订单号
    email = ('name', 'email')  # 电子邮箱
    buyer = ('name', 'user_name')  # 狗货人
    consignee = ('name', 'consignee')  # 收货人
    address = ('name', 'address')  # 地址
    zipcode = ('name', 'zipcode')  # 邮编
    tel = ('name', 'tel')  # 电话
    mobile = ('name', 'mobile')  # 手机
    select_country = ('name', 'country')  # 国家下拉框
    select_province = ('name', 'province')  # 省份下拉框
    select_city = ('name', 'city')  # 城市下拉框
    select_district = ('name', 'district')  # 地区下拉框
    select_shipping = ('name', 'shipping_id')  # 配送方式下拉框
    select_pay = ('name', 'pay_id')  # 支付方式下拉框
    start_time = ('id', 'start_time_id')  # 开始时间输入框
    start_Id = list(start_time)[1]
    end_time = ('id', 'end_time_id')  # 结束时间输入框
    end_Id = list(end_time)[1]
    select_order_status = ('name', 'order_status')  # 订单状态下拉框
    select_pay_status = ('name', 'pay_status')  # 付款状态下拉框
    select_shipping_status = ('name', 'shipping_status')  # 发货状态下拉框
    search_submit = ('name', 'query')  # 搜索按钮
    reset_submit = ('name', 'reset')  # 重置按钮
    search_result = ('id', 'order_0')  # 表中第一条数据订单号

    # 输入订单号
    def page_orderquery_input_ordersn(self, order_sn):
        self.base_input_massage(self.order_sn, order_sn)

    # 输入电子邮件
    def page_orderquery_input_email(self, email=None):
        self.base_input_massage(self.email, email)

    # 输入购货人
    def page_orderquery_input_buyer(self, buyer=None):
        self.base_input_massage(self.buyer, buyer)

    # 输入收货人
    def page_orderquery_input_consignee(self, consignee=None):
        self.base_input_massage(self.consignee, consignee)

    # 输入地址
    def page_orderquery_input_address(self, address=None):
        self.base_input_massage(self.address, address)

    # 输入邮编
    def page_orderquery_input_zipcode(self, zipcode=None):
        self.base_input_massage(self.zipcode, zipcode)

    # 输入电话
    def page_orderquery_input_tel(self, tel=None):
        self.base_input_massage(self.tel, tel)

    # 输入手机
    def page_orderquery_input_mobile(self, mobile=None):
        self.base_input_massage(self.mobile, mobile)

    # 选择国家
    def page_orderquery_select_country(self, text=None):
        self.base_drop_down_menu_by_text(self.select_country, text)
        time.sleep(3)

    # 选择省份
    def page_orderquery_select_province(self, text=None):
        self.base_drop_down_menu_by_text(self.select_province, text)
        time.sleep(3)

    # 选择城市
    def page_orderquery_select_city(self, text=None):
        self.base_drop_down_menu_by_text(self.select_city, text)
        time.sleep(3)

    # 选择地区
    def page_orderquery_select_district(self, text='None'):
        self.base_drop_down_menu_by_text(self.select_district, text)

    # 选择配送方式
    def page_orderquery_select_shipping(self, text='None'):
        self.base_drop_down_menu_by_text(self.select_shipping, text)

    # 选择支付方式
    def page_orderquery_select_pay(self, text='None'):
        self.base_drop_down_menu_by_text(self.select_pay, text)


    # 输入开始时间
    def page_orderquery_input_start_time(self, start_time):
        self.base_execute_script(self.start_Id)
        self.base_input_massage(self.start_time,start_time)



    # 输入结束时间
    def page_orderquery_input_end_time(self, end_time):
        self.base_execute_script(self.end_Id)
        self.base_input_massage(self.end_time, end_time)

    # 选择订单状态
    def page_orderquery_select_order_status(self, text=None):
        self.base_drop_down_menu_by_text(self.select_order_status, text)

    # 选择付款状态
    def page_orderquery_select_pay_status(self, text=None):
        self.base_drop_down_menu_by_text(self.select_pay_status, text)

    # 选择发货状态
    def page_orderquery_select_shipping_status(self, text=None):
        self.base_drop_down_menu_by_text(self.select_shipping_status, text)

    # 点击搜索按钮
    def page_orderquery_click_search(self):
        self.base_click(self.search_submit)

    # 获取订单号进行用于断言
    def page_orderlist_get_ordersn(self):
        return self.base_get_text(self.search_result)



if __name__ == '__main__':
    my_browser = create_loading_browser('yuan_jun')  # 创建配置项浏览器
    pagemenu_object = PageMenu(my_browser)  # 创建菜单页面对象
    pagemenu_object.page_menu_background_open()  # 打开后台端
    pagemenu_object.page_menu_into_menu_iframe()  # 进入menu-frame
    pagemenu_object.page_menu_click_ordermanage()   # 进入订单管理


    pagemenu_object.page_menu_click_orderquery()  # 进入订单查询页面
    pagemenu_object.page_menu_quit_iframe()  # 退出menu-frame
    pagemenu_object.page_menu_into_main_iframe()

    pageorderquery = PageOrderQuery(my_browser)
    pageorderquery.page_orderquery_input_ordersn('2016051183359')
    pageorderquery.page_orderquery_input_email()
    pageorderquery.page_orderquery_input_buyer()
    pageorderquery.page_orderquery_input_consignee()
    pageorderquery.page_orderquery_input_address()
    pageorderquery.page_orderquery_input_zipcode()
    pageorderquery.page_orderquery_input_tel()
    pageorderquery.page_orderquery_input_mobile()
    pageorderquery.page_orderquery_select_country('中国')
    time.sleep(3)
    pageorderquery.page_orderquery_select_province('北京')
    time.sleep(3)
    pageorderquery.page_orderquery_select_city()
    time.sleep(3)
    pageorderquery.page_orderquery_select_district()
    pageorderquery.page_orderquery_select_shipping()
    pageorderquery.page_orderquery_select_pay()
    pageorderquery.page_orderquery_input_start_time('2016-05-10 10:14')
    pageorderquery.page_orderquery_input_end_time('2016-05-13 10:13')
    pageorderquery.page_orderquery_select_order_status()
    pageorderquery.page_orderquery_select_pay_status()
    pageorderquery.page_orderquery_select_shipping_status()
    pageorderquery.page_orderquery_click_search()
